package vmcs.observer;


/**
 * 
 * Singleton to store instances of drink store item change maanger and cash store item change manager.
 * 
 * @author lai shiaw san
 *
 */
public class StoreItemChangeManagerRegistry {

	/**
	 * 
	 * Defines a fix set of store item type. 
	 * Safer than static constants. 
	 * 
	 * @author lai shiaw san
	 *
	 */
	public enum StoreItemType {
		/**
		 * Define the identifier for drink store item change manager.
		 */
		Drink,
		/**
		 * Define the identifier for cash store item change manager.
		 */
		Cash
	};

	/**
	 * Get the instance of store item change manager as indicated by type.
	 * @param type Type of store item change manager.
	 * @return Instance of store item change manager as indicated by type.
	 */
	public static StoreItemChangeManager getManager( StoreItemType type ) {
		switch ( type ) {
		case Drink : return drinkStoreItemChangeManager;
		case Cash  : return cashStoreItemChangeManager;
		}
		throw new ArrayIndexOutOfBoundsException( "Invalid type passed: " + type );
	}

	/**
	 * Only instance of drink store item change manager.
	 */
	private static final StoreItemChangeManager drinkStoreItemChangeManager = new DrinkStoreItemChangeManager();

	/**
	 * Only instance of cash store item change manager.
	 */
	private static final StoreItemChangeManager cashStoreItemChangeManager = new CashStoreItemChangeManager();
	
}
